package com.ja.openchat.ui.chat.multimsg;

import android.content.Context;

import androidx.lifecycle.ViewModelProvider;

import com.ja.openchat.R;
import com.ja.openchat.ui.chat.listener.OnDeleteDialogListener;
import com.zy.openchat.core.model.message.UiMessage;
import com.ja.openchat.ui.chat.MessageViewModel;

import java.util.List;

public class DeleteMultiMessageAction extends MultiMessageAction {

    @Override
    public void onClick(List<UiMessage> messages) {
        MessageViewModel messageViewModel = new ViewModelProvider(fragment).get(MessageViewModel.class);
        fragment.deleteMessages(new OnDeleteDialogListener() {
            @Override
            public void onDeleteRevoke(boolean isJustMeDelete) {
                for (UiMessage message : messages) {
                    if(isJustMeDelete){
                        messageViewModel.deleteMessage(message.message);
                    }else{
                        messageViewModel.deleteOrRevoke(message.message,true);
                    }
                }
            }
        });
    }

    @Override
    public int iconResId() {
        return R.drawable.menu_shanchu1_selector;
    }

    @Override
    public String title(Context context) {
        return context.getString(R.string.delete_text);
    }

    @Override
    public boolean confirm() {
        return false;
    }

}
